'''
自定义进程：进程Process这个类，主要的是重写run()方法
'''

import multiprocessing import Process
from time import sleep
import random


class MyProcess(Process):
	def __init__(self, c_name):  # 如果想传入参数
		super(MyProcess, self).__init__()
		self.cname = c_name

	# 重写run方法
	def run(self):
		n = 1
		while True:
			t = random.choice([0.3,0.5,0.8,1])
			print('进程：{}--n：{} [{}] --t:'.format(self.name, n, self.cname),t)
			n += 1
			sleep(t)
		
if __name__ == '__main__':
	p0 = MyProcess('糖糖')
	p1 = MyProcess('尚尚')
	
	p0.start()
	p1.start()